﻿using System;
using Telerik.Windows.Diagrams.Core;

namespace Samurai.WorkflowGraph.ViewModels
{
    /// <summary>
    /// Base class for MVVM nodes.
    /// </summary>
    public class NodeViewModelBase : ItemViewModelBase
    {
        private double _height = double.NaN;
        private bool _isSelected;
        private double _rotationAngle;
        private double _width = double.NaN;

        /// <summary>
        /// Gets or sets the width.
        /// </summary>
        /// <value>
        /// The width.
        /// </value>
        public double Width
        {
            get { return _width; }
            set
            {
                if (_width != value)
                {
                    _width = value;
                    OnPropertyChanged("Width");
                }
            }
        }

        /// <summary>
        /// Gets or sets the height.
        /// </summary>
        /// <value>
        /// The height.
        /// </value>
        public double Height
        {
            get { return _height; }
            set
            {
                if (_height != value)
                {
                    _height = value;
                    OnPropertyChanged("Height");
                }
            }
        }

        /// <summary>
        /// Gets or sets the rotation of the shape.
        /// </summary>
        public double RotationAngle
        {
            get { return _rotationAngle; }
            set
            {
                if (Math.Abs(_rotationAngle - value) > Utils.Epsilon)
                {
                    _rotationAngle = value;
                    OnPropertyChanged("RotationAngle");
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is selected.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is selected; otherwise, <c>false</c>.
        /// </value>
        public bool IsSelected
        {
            get { return _isSelected; }
            set
            {
                if (IsSelected != value)
                {
                    _isSelected = value;
                    OnPropertyChanged("IsSelected");
                }
            }
        }
    }
}